package com.appwoo.txtws.util;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.ImageHelper;
import java.util.ArrayList;

public class DialogDateAdapter extends BaseAdapter
{
  private Context context;
  private DBHelper dbHelper;
  int i;
  private Boolean isSDCard = Boolean.valueOf(false);
  private ArrayList<AutoSoftInfo> lstDate;
  private PackageManager pm;
  private Resources res;

  public DialogDateAdapter(Context paramContext, ArrayList<AutoSoftInfo> paramArrayList, DBHelper paramDBHelper)
  {
    this.context = paramContext;
    this.res = this.context.getResources();
    this.lstDate = paramArrayList;
    this.isSDCard = Boolean.valueOf(Global.isSDCard());
    this.pm = this.context.getPackageManager();
    this.dbHelper = paramDBHelper;
  }

  public void exchange(int paramInt1, int paramInt2)
  {
    AutoSoftInfo localAutoSoftInfo1;
    AutoSoftInfo localAutoSoftInfo2;
    if (paramInt1 != paramInt2)
    {
      localAutoSoftInfo1 = (AutoSoftInfo)getItem(paramInt2);
      localAutoSoftInfo2 = (AutoSoftInfo)getItem(paramInt1);
      if ((localAutoSoftInfo1.getAsIsFolder() != 0) || (localAutoSoftInfo1.getAsParentid() != 0) || (localAutoSoftInfo2.getAsIsFolder() != 0))
        break label86;
      localAutoSoftInfo2.setAsParentid(localAutoSoftInfo1.getAsid());
      localAutoSoftInfo1.setAsParentid(localAutoSoftInfo1.getAsid());
      localAutoSoftInfo1.setAsIsFolder(1);
      localAutoSoftInfo1.setAsFolderName("文件夹");
      this.dbHelper.changeToFolder(localAutoSoftInfo1, localAutoSoftInfo2);
    }
    label86: 
    do
    {
      return;
      if (localAutoSoftInfo1.getAsIsFolder() == 1)
      {
        localAutoSoftInfo2.setAsParentid(localAutoSoftInfo1.getAsid());
        this.lstDate.add(paramInt1, localAutoSoftInfo2);
        this.lstDate.remove(paramInt1 + 1);
        this.dbHelper.updateParentid(localAutoSoftInfo2.getAsid(), localAutoSoftInfo2.getAsParentid());
        return;
      }
    }
    while ((localAutoSoftInfo1.getAsIsFolder() != 0) || (localAutoSoftInfo1.getAsParentid() != 1) || (localAutoSoftInfo2.getAsIsFolder() != 0));
    int j = localAutoSoftInfo2.getAsid();
    localAutoSoftInfo2.setAsid(localAutoSoftInfo1.getAsid());
    localAutoSoftInfo1.setAsid(j);
    this.lstDate.add(paramInt1, localAutoSoftInfo1);
    this.lstDate.remove(paramInt1 + 1);
    this.lstDate.add(paramInt2, localAutoSoftInfo2);
    this.lstDate.remove(paramInt2 + 1);
    this.dbHelper.changeOrder(localAutoSoftInfo2, localAutoSoftInfo1);
  }

  public int getCount()
  {
    return this.lstDate.size();
  }

  public Object getItem(int paramInt)
  {
    return this.lstDate.get(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView = LayoutInflater.from(this.context).inflate(2130903108, null);
    AutoSoftInfo localAutoSoftInfo = (AutoSoftInfo)this.lstDate.get(paramInt);
    ImageView localImageView = (ImageView)localView.findViewById(2131493119);
    TextView localTextView = (TextView)localView.findViewById(2131493122);
    while (true)
    {
      try
      {
        if (((AutoSoftInfo)this.lstDate.get(paramInt)).getActivityName() == null)
        {
          ImageHelper.loadLogoImage(this.context, localImageView, ((AutoSoftInfo)this.lstDate.get(paramInt)).getAdicon(), this.isSDCard);
          localTextView.setText(localAutoSoftInfo.getAsname());
          return localView;
        }
        this.pm.getApplicationInfo(localAutoSoftInfo.getAspkg(), 8192);
        if ("com.huawei.android.ChinaTelecomCustomize".equals(((AutoSoftInfo)this.lstDate.get(paramInt)).getAspkg()))
        {
          localImageView.setImageDrawable(this.context.getResources().getDrawable(2130838080));
          localTextView.setText(this.pm.getActivityInfo(new ComponentName(localAutoSoftInfo.getAspkg(), localAutoSoftInfo.getActivityName()), -1).loadLabel(this.pm).toString());
          return localView;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return localView;
      }
      localImageView.setImageDrawable(this.pm.getActivityIcon(new ComponentName(localAutoSoftInfo.getAspkg(), localAutoSoftInfo.getActivityName())));
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.util.DialogDateAdapter
 * JD-Core Version:    0.6.2
 */